package com.zjhome.cloudnote.service;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.zjhome.cloudnote.domain.NoteInfo;

/**
 * 笔记服务
 * 
 * @author zjhome
 *
 */
public interface NoteService {
	/**
	 * 根据id查询笔记详情
	 * 
	 * @param id	笔记id
	 * @return
	 * @throws Exception
	 */
	NoteInfo selectNoteById(@Param("id") String id, @Param("uid") String uid) throws Exception;
	
	/**
	 * 查询指定用户下的笔记
	 * 
	 * @param uid	用户id
	 * @return
	 * @throws Exception
	 */
	List<NoteInfo> selectAllNotesByUserid(@Param("uid")String uid) throws Exception;
	
	/**
	 * 查询指定文件下的子文件
	 * 
	 * @param did	目录id
	 * @param uid 	用户id
	 * @return
	 * @throws Exception
	 */
	List<NoteInfo> selectSubNotesByDid(@Param("did") String did, @Param("uid") String uid) throws Exception;
	
	/**
	 * 查询满足条件的笔记
	 * 
	 * @param noteInfo	笔记过滤参数
	 * @return
	 * @throws Exception
	 */
	List<NoteInfo> selectNotesByParam(NoteInfo noteInfo) throws Exception;
		
	
	/**
	 * 查询共享笔记信息
	 * 
	 * @param noteInfo
	 * @return
	 * @throws Exception
	 */
	List<NoteInfo> selectShareNotes(NoteInfo noteInfo) throws Exception;
	
	/**
	 * 添加新笔记
	 * 
	 * @param note
	 * @return
	 * @throws Exception
	 */
	int insertNoteByParam(NoteInfo noteInfo) throws Exception;
	
	/**
	 * 更改笔记 
	 * 
	 * @param note
	 * @return
	 * @throws Exception
	 */
	int updateNoteByParam(NoteInfo noteInfo) throws Exception;
	
	/**
	 * 更新指定文件夹下的 笔记的 删除标志
	 * 
	 * @param pid		父文件夹id
	 * @param uid		用户id
	 * @param delflag	删除标志状态
	 * @return
	 * @throws Exception
	 */
	int updateNoteDelFlagByDir(String pid, String uid, int delflag) throws Exception;
	
	
	/**
	 * 删除笔记
	 * 
	 * @param id	笔记id
	 * @param uid	用户id
	 * @return
	 * @throws Exception
	 */
	int deleteNoteById(String id, String uid) throws Exception;

	/**
	 * 删除文件下的所有笔记（递归嵌套）
	 * 
	 * @param pid	父文件夹id
	 * @param uid	用户id
	 * @return
	 * @throws Exception
	 */
	int deleteSubNoteById(String pid, String uid) throws Exception;
		
	/**
	 * 配置笔记共享标志
	 * 
	 * @param id
	 * @param uid
	 * @param flag
	 * @return
	 * @throws Exception
	 */
	NoteInfo setNoteShareConfig(String id, String uid, int flag) throws Exception;
	
	
	/**
	 * 获取分享文章
	 * 
	 * @param url	分享url（短路由）
	 * @return
	 * @throws Exception
	 */
	NoteInfo selectShareNote(String url) throws Exception;
}
